<?php
include_once "../header1.php";
?>

</head>
<body>
<?php
include_once ("$basedir"."/Login/databaseconnection.php");

if(!loggedin())
{
	require_once ("$basedir"."/index.php");
}
else
{	
if(isset($_POST['Search']))
{
if($School_Id=="Select One")
{
	$_SESSION['error']="Please select the School Id!";
}
$School_Id=$_POST['School_Id'];
if($School_Id!="Select One")
{
$tnic=mysql_query("SELECT * FROM teacher WHERE School_Id='$School_Id'");
if($rown=mysql_fetch_array($tnic))
 {
 $nic_no=$rown['T_NIC_Number'];
	$re_te=mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$nic_no'");
	if(mysql_num_rows($re_te)==0)
	{
		$_SESSION['errornor']="Sorry there is no resource person for this school!";
	}
}
}
}
?>
 <?php

include_once "../header2.php";


?>
<?php
include_once "topmenu.php";
?>
<div class="left">
  
<div class="articles">
<form method="POST" action="#">
  <table width="792" height="127" border="0">
      <tr>
        <td height="22" colspan="6" align="left" scope="row">
		<?php
		if(isset($_POST['Search']))
{
	if(isset($_SESSION['error']))
	{
		echo $_SESSION['error'];
		unset($_SESSION['error']);
	}
	if(isset($_SESSION['errornor']))
	{
		echo $_SESSION['errornor'];
		unset($_SESSION['errornor']);
	}
}
		?>        </td>
        </tr>
      <tr>
        <td width="111" rowspan="2" align="left" scope="row">Search by</td>
      <td width="167" height="22" align="left" scope="row">School Id:</td>
      <td width="246" align="left" scope="row">:-</td>
      <td width="135"><select name="School_Id" id="select">
       <?php
	 if(isset($_POST['Search']))
{
	 echo '<option value="'.$School_Id.'">'.$School_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
        <?php
	 $tea=mysql_query("SELECT DISTINCT(School_Id) FROM teacher");
	  
  while($row=mysql_fetch_array($tea))
  {
	 $Sch_Id=$row['School_Id'];
if($Sch_Id!=$School_Id)
{	 
 echo '<option value="'.$Sch_Id.'">'.$Sch_Id.'</option>';
}
  }
  
	  ?>
      </select></td>
      <td width="71">Other Way:</td>
      <td width="246"><table width="225" border="1">
        <tr>
          <td width="215"><input type="text" name="textfield3" />
              <input name="SearchOther" align="middle" type="submit" value="Search" />          </td>
        </tr>
      </table></td>
      </tr>
    <tr>
      <td width="167">&nbsp;</td>
      <td width="246">&nbsp;</td>
    </tr>
    <tr>
      <th height="34" colspan="2" align="left" scope="row"><p><a href="searchtea.php">Reset</a>|
       <input name="Search" align="middle" type="submit" value="Search" /> </th>
  </table>
  </form>
  <?php
  
if(isset($_POST['Search']))
{
 $School_Id=$_POST['School_Id'];
if($School_Id!="Select One"&&$School_Id!="")
{

if(mysql_num_rows($re_te)!=0)
	{
if($rowrt=mysql_fetch_array($re_te))
 {
  echo '<table  border="1">';
 echo '	<tr align="center">';
echo '<td width="94">';
echo "Training Id";
echo '</td>';
echo '<td width="94">';
echo "Member Id";
echo '</td>';
echo '<td width="194">';
echo "Teacher NIC Number";
echo '</td>';
echo '<td width="94">';
echo "From Date";
echo '</td>';
echo '</tr>';
 	echo '<tr align="center">';
	echo '<td>'.$rowrt['Training_Id'].'</td>';
	echo '<td>'.$rowrt['Member_Id'].'</td>';
	echo '<td>'.$rowrt['T_NIC_Number'].'</td>';
	echo '<td>'.$rowrt['From_Date'].'</td>';
	echo '</tr>';
     echo "</table>";
	}
  }
	
  }
  if($School_Id=="Select One"||$School_Id=="")
{
$_SESSION['error']="Please select the School Id!";
}
	} 
	?>
       <?php
}
?>
   
</div>

</div>


<div class="rightmenu"> 
<?php
include_once "menu.php";
?>
<?php
include_once "../footer.php";
?>
</body>
</html>